<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>音频播放器</title>
<style>
    body {
        font-family: Arial, sans-serif;
        margin: 0;
        padding: 0;
        text-align: center;
    }
    h1 {
        margin-top: 20px;
    }
    .audio-container {
        margin: 50px auto;
        width: 80%;
        max-width: 400px;
    }
    audio {
        width: 100%;
    }
    button {
        margin-top: 20px;
        padding: 10px 20px;
        border: none;
        border-radius: 5px;
        background-color: #3498db;
        color: #fff;
        font-size: 16px;
        cursor: pointer;
        transition: background-color 0.3s;
    }
    button:hover {
        background-color: #2980b9;
    }
</style>
</head>
<body>
<h1>音频播放器</h1>
<div class="audio-container">
    <audio controls id="audio" src="audio.mp3"></audio>
    <button id="playPauseBtn">播放/暂停</button>
</div>
<script src="axios.min.js"></script>
<script>
  const urlParams = new URLSearchParams(window.location.search);
  const queryString = urlParams.toString();
  const originData = {};
  urlParams.forEach((value, key) => {
    originData[key] = value;
  });
  console.log(originData);
  const name = originData.name
  const album = originData.album
  console.log(name);
  console.log(album);

  axios({
    url:`http://localhost:8080/song/detail?name=${name}&album=${album}`,
    method:"get"
  }).then(result=> {
    const data = result.data.data
    const videoContainer = document.querySelector(".audio-container")
    const video = document.querySelector("audio")
    audio.src = data.music;
  })
    const audio = document.getElementById('audio');
    const playPauseBtn = document.getElementById('playPauseBtn');
    playPauseBtn.addEventListener('click', function() {
        if (audio.paused) {
            audio.play();
            playPauseBtn.textContent = '暂停';
        } else {
            audio.pause();
            playPauseBtn.textContent = '播放';
        }
    });
</script>
</body>
</html>